package com.xtck.ha.fault.modules.controller;


import com.xtck.ha.fault.framework.utils.JsonResult;
import com.xtck.ha.fault.modules.pojo.entity.CalculateData;
import com.xtck.ha.fault.modules.pojo.entity.FmeaInfo;
import com.xtck.ha.fault.modules.pojo.entity.ModFaultModPost;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
*  controller
*
* @ClassName: MockFaultModController
* @Description: 控制层访问接口
* @author liuyuan
* @date 2025-06-17
*/
@RestController
@RequestMapping("/mockFaultMod")
@Api(tags={"模拟故障模型接口管理"})
public class MockFaultModController {


    @PostMapping({"/doProcess"})
    @ApiOperation(value = "流程调用")
    public JsonResult<FmeaInfo> mokFaultMod(@RequestBody ModFaultModPost modFaultModPost){
        List<CalculateData> dataList = modFaultModPost.getDataList();
        if (null != dataList && dataList.size()!=0){
            FmeaInfo fmeaInfo = FmeaInfo.builder()
                    .failureMode("模式A")
                    .effect("部分故障")
                    .severity(2)
                    .cause("电压波动")
                    .occurrence("30%")
                    .currentProcessControlPlan("方法C")
                    .detection("具备")
                    .rpn(36)
                    .recommendedAction("维修变压器")
                    .build();
            return JsonResult.ok(fmeaInfo);
        }
        else
            return JsonResult.error("入参为空，无法计算");
    }

}
